#ifndef _NETWORKHANDLER_
#define _NETWORKHANDLER_

#include "ClientCollection.hpp"
#include "Networking/Networking.hpp"
#include "Networking/PacketHelper.hpp"

/** 
 * Common network functionality for sending and receiving messages.
 */
class NetworkHandler{
private:
	/** NetworkHandler singleton for global access. */
	static NetworkHandler* currentInstance;
protected:
	
	/** Pointer to the server's ClientCollection for network access to all clients. */
	ClientCollection* clientCollection;

public:
	
	NetworkHandler();

	static NetworkHandler* getInstance();

	void setClientCollection(ClientCollection* cc);

	void sendAllMessage(Message::MessageCode code, void* data);
    void sendAllMessageInArea(Message::MessageCode code, void* data, float x, float y);
    void sendAllChatMessage(const char* message);
    void sendAllMessageExcept(Message::MessageCode code, void* data, int except);
	~NetworkHandler();
};

#endif